//
//  NavigationController.m
//  WWTQ
//
//  Created by JP on 2018/11/8.
//  Copyright © 2018年 Jqert. All rights reserved.
//

#import "NavigationController.h"
#import "GQGesVCTransition.h"

@interface NavigationController ()

@end

@implementation NavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //一句话给你的app添加手势返回
    [GQGesVCTransition validateGesBackWithType:GQGesVCTransitionTypePanWithPercentRight withRequestFailToLoopScrollView:YES];
    
    UIColor *barTitleColor = ZYTBlack1Color;
    self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:barTitleColor};
    self.navigationBar.tintColor = barTitleColor;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    [super pushViewController:viewController animated:animated];
    
    self.interactivePopGestureRecognizer.delegate = (id)self;
    self.interactivePopGestureRecognizer.enabled = YES;
    if (self.viewControllers.count > 1) {
        [viewController setHidesBottomBarWhenPushed:YES];
        UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 40, 44)];
        UIButton *backBtn = [[UIButton alloc]initWithFrame:CGRectMake(-10, 0, 50, 44)];
        [backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        backBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 20);
        [leftView addSubview:backBtn];
        [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftView];
    }
}

- (void)back {
    [self popViewControllerAnimated:YES];
}

#pragma mark - 解决隐藏状态栏侧滑 BUG
- (UIViewController *)childViewControllerForStatusBarStyle {
    return self.visibleViewController;
}

@end
